Reorganize repo into dirs + central run cmd#11
Merged
Conversation
Signed-off-by: Josef Karasek <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR reorganizes the CLI code into clearer subpackages (auth/get/list/apply) and introduces a shared Context plus service interfaces to centralize dependencies, making it easier to add and maintain commands as the repo grows.
Changes:
- Split monolithic
internal/clicommand implementations into dedicated subpackages (auth,get,list,apply) while keeping a centralinternal/cli.Runentrypoint. - Introduce shared dependency contracts (
internal/service) and a shared command runtime context (internal/cli/context.Context). - Restructure and expand tests to match the new package layout, replacing the previous all-in-one
commands_test.go.
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/service/credentials_store.go | Adds a credentials storage interface and config-backed implementation for injection into commands. |
| internal/service/cluster.go | Adds a cluster service interface for dependency injection. |
| internal/output/output.go | Adds a small wrapper (WriteOutput) used as an injectable output function. |
| internal/errors/errors.go | Introduces CommandResultError for returning exit code + structured payload from commands. |
| internal/cli/run.go | Centralizes wiring of dependencies and routes commands to subpackages; handles CommandResultError output/exit codes. |
| internal/cli/recommendations.go | Deleted; functionality moved into internal/cli/list/recommendations.go. |
| internal/cli/output.go | Deleted; replaced by internal/output.WriteOutput wrapper for injection. |
| internal/cli/login.go | Deleted; functionality moved into internal/cli/auth/login.go. |
| internal/cli/list/recommendations.go | New list subcommand implementation using shared context + injected dependencies. |
| internal/cli/list/recommendations_test.go | Adds targeted tests for listing recommendations. |
| internal/cli/list/clusters.go | New list subcommand implementation using shared context + injected dependencies. |
| internal/cli/list/clusters_test.go | Adds targeted tests for listing clusters. |
| internal/cli/list.go | Deleted; functionality moved into internal/cli/list/clusters.go. |
| internal/cli/get/cluster.go | Moves get-cluster command into get package and updates to use shared context. |
| internal/cli/get/cluster_test.go | Adds targeted tests for get-cluster behaviors. |
| internal/cli/deps.go | Deleted; replaced by internal/service/credentials_store.go and context wiring in run.go. |
| internal/cli/context/context.go | New shared command context and shared token resolution helper. |
| internal/cli/context/context_test.go | Adds tests for ResolveToken. |
| internal/cli/commands_test.go | Deleted; replaced by package-scoped tests in new subpackages. |
| internal/cli/auth/token.go | New auth token command implementation using shared context. |
| internal/cli/auth/token_test.go | Adds tests for the auth token command. |
| internal/cli/auth/login.go | New login command implementation using shared context and credentials store. |
| internal/cli/auth/login_test.go | Adds tests for the login command. |
| internal/cli/auth.go | Deleted; replaced by internal/cli/context.ResolveToken. |
| internal/cli/auth_token.go | Deleted; functionality moved into internal/cli/auth/token.go. |
| internal/cli/apply/recommendations.go | Moves apply-recommendations command into apply package and updates to use shared context + CommandResultError. |
| internal/cli/apply/recommendations_test.go | Updates tests to call the command directly and to match new package-relative testdata paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jkremser
approved these changes
Jul 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Codex generated files were all in the same dir - adding new commands was getting difficult.